/*************************************************************************
 * @file: loop.h
 * @date: 01/04/2012
 * TOPOL v1_0 - (c)copyright 2012 TEC/UFF
 *************************************************************************
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 ************************************************************************/

#ifndef _LOOP
#define _LOOP

// includes
//----------

// forward declarations
//----------------------
class Face;
class HalfEdge;


/*!
 * CLASS
 * Loop
 * 
 * This class implements the requirement for the topological entity named
 * Loop and sets all the necessary adjacency informations
 * 
 * @author Andre Pereira (andremaues@id.uff.br)
 * @version 1.0.0
 * @see Face
 * @see HalfEdge
 */
class Loop
{

public:

  ////////////////////////////////////////////////
  ///  Constructor and Destructor Declaration  ///
  ////////////////////////////////////////////////

  /**
   * @brief Constructs a loop and attaches it into a given Face object
   * @param _f is a Face object
   */
	Loop( Face* _f );

  /**
   * @brief Destructs the Loop object
   */
  ~Loop();

  ////////////////////////////////////
  ///  PUBLIC Methods Declaration  ///
  ////////////////////////////////////

  /**
   * @brief Gets the previous loop
   * @return Loop* pointer to the previous loop object
   */
	Loop* getPrevLoop();

  /**
   * @brief Gets the next loop
   * @return Loop* pointer to the next loop object
   */
  Loop* getNextl();

  /**
   * @brief Gets the face associated with the loop
   * @return Face* pointer to the face which contains the loop
   */
	Face* getFace();

  /**
   * @brief Gets a half-edge of the loop
   * @return HalfEdge* pointer to a element in the list of half-edges of the loop
   */
	HalfEdge* getLedg();

  /**
   * @brief Computes the area of the loop
   * @return double value of the area delimited by the loop
   */
  double getArea();	

  /**
   * @brief Obtains the coordinates of the centroid area of the loop
   * @param _xc coordinate X of the centroid
   * @param _yc coordinate Y of the centroid
   * @param _zc coordinate Z of the centroid
   */
  void getCenter( double& _xc, double& _yc, double& _zc );	


  void getMonentOfInertia( double& _Ixx, double& _Iyy, double& _Ixy );	


  /**
   * @brief Sets a half-edge of the loop
   * @param _newhe the half-edge of the loop
   */
  void setLedg( HalfEdge* _newhe );

  /**
   * @brief Sets the loop that is previous to the current one
   * @param _l is the previous loop
   */
  void setPrv( Loop* _l );

  /**
   * @brief Sets the loop that is next to the current one
   * @param _l is the next loop
   */
  void setNxt( Loop* _l );

  void setLFace( Face* _f );


private:

  ////////////////////////////////
  ///  Attributes Declaration  ///
  ////////////////////////////////

  /** @brief Pointer to the previous loop */
	Loop* m_prevl;

  /** @brief Pointer to the next loop */
	Loop* m_nextl;

  /** @brief Pointer to the ring of half-edges */
	HalfEdge* m_ledg;

  /** @brief Back pointer to the face */
	Face* m_lface;

};

#endif
